Some conventional coding apparatuses (encoders) that improve transmission efficiency of coded data determine a quantization width based on buffer amount (for example, refer to document 1).
FIG. 1 is a block diagram showing the structure of a conventional encoder (coding apparatus) described in the above-mentioned document.
As shown in FIG. 1, a conventional audio encoder 200 includes a coding unit 202, a packetization unit 204, a quantization width calculation unit 206 and the like.
The coding unit 202 receives an input of audio data 201 and calculates coded data size inside. The coding unit 202 generates coded data in a way that the coded data falls within the calculated coded data size, and the generated coded data is stored in the sequential storage unit 203. The data stored in the storage unit 203 is divided into packets 205 by the packetization unit 204. The storage unit 203 transfers the stored data size to the quantization width calculation unit 206, and the quantization width calculation unit 206 transfers the quantization width to the coding unit 202.
In the case where the size of the coded data outputted by the coding unit 202 is variable length, the total size of the data stored in the storage unit 203 is also variable length.
The procedure at the time of dividing the data stored by the storage unit 203 will be shown in FIG. 2.
The coded data stored by the storage unit 203 is called as elementary stream (abridged as ES from here). As to audio data, ESs are made in a plurality of audio frames 301, 302 and 308.
Next, these ESs are converted into a packetized elementary stream (abridged as PES). ESs are converted into PESs by adding a PES header 303 to ESs, and the whole is called as PES packet. In the PES packet, the data part stored by the storage unit 203 is called PES payload 304. This PES packet is converted into a transport stream (called TS from here). This PES packet is divided into fixed lengths, and the TS header 305 is added to each of the packets so as to make each of the corresponding TS packets. A TS payload 306 follows the TS header. In mapping from an ES to a PES or a TS, there may be a case of mapping an integer number of audio frames onto a single PES packet and mapping in a way that a single audio frame is not divided into plural PES packets, and also, mapping in a way that a single TS packet is not divided into plural PES packets with a view to making it easier to access on an audio frame basis as shown in FIG. 2.
Japanese Laid-Open Patent application No. 2001-292448 publication.
However, in a conventional audio encoder, in the above-mentioned case, there is a case where padding 307 is generated on a PES packet basis when dividing the PES packet into TS packets. Especially, percentage of the padding in the size of the PES packet becomes bigger when the size of the PES packet is small, and there emerges a problem that the transmission efficiency of the TS packets decreases.
Also, it is possible to improve the transmission rate of the TS packets by changing the coded data size in order to restrain padding. However, there is a problem that sound quality deteriorates when changing coded data size, to be more specific, reducing the coded data size or always changing the coded data size during the encode processing with no restriction.
The first object of the present invention is to provide a coding apparatus that solves the above-mentioned first problem, that is, to reduce the padding data and improve the transmission efficiency.
Also, the second object of the present invention is to provide a coding apparatus that solves the above-mentioned second problem and minimize sound deterioration improving the transmission efficiency.